package liangtWorkSpace.threadDemo.thread;

import lombok.SneakyThrows;

import java.util.Random;

/**
 * @author liangt
 * @ClassName: Match1
 * @title: Match1
 * @projectName liangtWorkSpace.threadDemo.thread
 * @description: TODO
 * @date 2020/11/3 11:47
 */
public class RunnerAble implements Runnable{
    public static void main(String[] args) {
        Thread thread = new Thread(new RunnerAble());
        Thread zhangsan = new Thread(new RunnerAble());
        zhangsan.setName("张三");
        thread.setName("刘翔");
        thread.start();
        zhangsan.start();
    }
    @SneakyThrows
    @Override
    public void run() {
        Integer speed = new Random().nextInt(100);
        for (int i = 0; i < 100 ; i++){
            Thread.sleep(10);
            System.out.println(Thread.currentThread().getName()+ "跑了"+speed*i+"米（"+speed+"米/秒）");
        }
    }
}

